<template></template>

<script lang="ts" setup>
interface IProps {
  data: any;
}

const props = withDefaults(defineProps<IProps>(), {
  data: {},
});

let cimInstance: any;
const render = () => {
  try {
    const data = { ...props.data, ...props.data?.data };
    cimInstance.api.addLayerByType(data);
  } catch (error) {
    console.log(error);
  }
};

watch(props.data, () => {
  render();
});

onMounted(() => {
  cimInstance = window.cimInstance;
  render();
});

onUnmounted(() => {
  cimInstance.api.destroyLayer(props.data?.layerId);
});
</script>

<style lang="less" scoped></style>
